package com.itcam.string_;

public class StringExercise {
    public static void main(String[] args) {
        String a = "abc";
        String b = "abc";
        System.out.println(a == b);//true
        System.out.println(a.equals(b));//true

        String c = "cammy";
        String d = new String("cammy");
        System.out.println(c == d);//false
        System.out.println(c.equals(d));//true
        // 当调用 intern() 方法时，编译器会将字符串添加到常量池中
        System.out.println(c == d.intern());//true

        String e = new String("kim");
        String f = new String("kim");
        System.out.println(e == f);//false
        System.out.println(e.equals(f));//true
    }
}
